# 定义一个封装通用断言的函数
import json

import app


def assert_common_util(self, response, status_code, success, code, message):
    self.assertEqual(status_code, response.status_code) # 断言响应状态码
    self.assertEqual(success, response.json().get("success"))  # 断言success
    self.assertEqual(code, response.json().get("code"))  # 断言code
    self.assertIn(message, response.json().get("message"))  # 断言message


def read_login_data(filename):
    with open(filename,mode="r",encoding="utf-8")as f:
        jsonData = json.load(f)
        # print(jsonData)
        temp_list = []
        for login_data in jsonData:
            temp_list.append(tuple(login_data.values()))
            print(temp_list)
    return temp_list

# read_login_data("./data/login.json")


def read_emp_data(filename,option):
    with open(filename,mode="r",encoding="utf-8")as f:
        jsonData = json.load(f)
        print("加载的员工数据为：", jsonData)
        emp_data = jsonData.get(option)
        print("emp_data的结果为:",emp_data)
        emp_list = list()
        emp_list.append(tuple(emp_data.values()))
    print(emp_list)
    return emp_list
read_emp_data(app.BASE_DIR+"/data/employee.json","add_emp")

